package com.danicsoft.daide.serverclient;

/**
 * The state that the player is in.
 * 
 * @author Daniel Yule (daniel.yule@gmail.com)
 * @version 1.0
 */
public enum PLAYER_STATE {
	/**
	 * The client is currently not connected to the server.
	 */
	NOT_CONNECTED,
	/**
	 * The client has generated an error.
	 */
	ERROR,
	/**
	 * The player is currently observing.
	 */
	OBSERVING,
	/**
	 * The client is currently processing the map.
	 */
	PROCESSING_MAP,
	/**
	 * The client is ready to play
	 */
	READY_TO_PLAY,
	/**
	 * The client has not yet submitted orders for this turn.
	 */
	SUBMITTING_ORDERS,
	/**
	 * The orders have been submitted.
	 */
	ORDERS_SUBMITTED,
	/**
	 * We are ready for the server to process the orders at any time.
	 */
	READY_TO_PROCESS,
	/**
	 * This power is currently in Civil disorder
	 */
	CIVIL_DISORDER;

	// switch(this) {
	// case CIVIL_DISORDER:
	// case ERROR:
	// case NOT_CONNECTED:
	// case OBSERVING:
	// case ORDERS_SUBMITTED:
	// case PROCESSING_MAP:
	// case READY_TO_PLAY:
	// case READY_TO_PROCESS:
	// case SUBMITTING_ORDERS:
	// }

	/**
	 * Returns true if this state means we are ready to play.
	 * 
	 * @return True if we are ready to play, or already playing.
	 */
	public boolean isReadyToPlay() {
		switch (this) {
			case CIVIL_DISORDER:
			case ERROR:
			case NOT_CONNECTED:
			case PROCESSING_MAP:
				return false;
			case OBSERVING:
			case ORDERS_SUBMITTED:
			case READY_TO_PLAY:
			case READY_TO_PROCESS:
			case SUBMITTING_ORDERS:
				return true;
		}
		return false;
	}

	/**
	 * Finds whether or not this is an observing state.
	 * @return True if its an observing state.
	 */
	public boolean isObserver() {
		 return this == OBSERVING;
	}

}
